/*
 * @Author: Tendo 
 * @Date: 2021-09-06 14:29:18 
 * @param {ListNode} head
 * @param {number} val
 * @return {ListNode}
 * @desc 添加虚节点方式
 */
/**
 * Definition for singly-linked list.
 * function ListNode(val, next) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.next = (next===undefined ? null : next)
 * }
 */
var removeElements = function(head, val) {
    const fake = new ListNode(0, head);
    let cur = fake;
    while(cur.next) {
        if(cur.next.val === val) {
            cur.next = cur.next.next
            continue
        }
        cur = cur.next
    }
    return fake.next
};
